package com.example.mallproduct.controller.web;

import com.example.mallproduct.controller.vo.SpuItemVO;
import com.example.mallproduct.service.SkuInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.concurrent.ExecutionException;


/**
 * @author guanglin.ma
 * @date 2023-12-30 10:04
 */
@Controller
public class ItemController {

    @Autowired
    SkuInfoService skuInfoService;

    @GetMapping("/{skuId}.html")
    public String item(@PathVariable Long skuId, Model model) throws ExecutionException, InterruptedException {
        SpuItemVO itemVO = skuInfoService.skuDetails(skuId);
        System.out.println(itemVO);
        model.addAttribute("item",itemVO);
        return "item";
    }
}
